package com.yantong.controller;

import com.yantong.constant.ActivityType;
import com.yantong.pojo.Activity;
import com.yantong.pojo.ActivityProduct;
import com.yantong.pojo.ActivityProductExample;
import com.yantong.pojo.ActivityProductSku;
import com.yantong.pojo.ActivityParam;
import com.yantong.mapper.ActivityProductMapper;
import com.yantong.service.ActivityService;
import com.yantong.pojo.Category;
import com.yantong.service.CategoryService;
import com.yantong.annotation.Log;
import com.yantong.result.ResultVo;
import com.yantong.utils.PageUtils;
import com.yantong.pojo.ProductSkuCentre;
import com.yantong.mapper.ProductSkuCentreMapper;
import com.yantong.service.ProductAuthorityService;
import com.yantong.pojo.ListMemberParams;
import com.yantong.pojo.Member;
import com.yantong.pojo.StoreFreecharge;
import com.yantong.pojo.vo.StoreFreechargeVo;
import com.yantong.service.CommanderListService;
import com.yantong.service.MemberService;
import com.yantong.service.StoreFreeChargeService;
import com.yantong.utils.ValidateUtil;
import com.yantong.pay.yfz.util.StringUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;

import java.math.BigDecimal;
import java.util.Collections;
import java.util.List;
import java.util.Map;

/**
 * 营销活动管理
 *
 * @author kanghaixin
 * @date 2018/9/7.15:39
 */

@Controller
@RequestMapping("/activity/manage")
public class ActivityController extends BaseController {
    private static final String prefix = "activity";
    private static final Logger logger = LoggerFactory.getLogger(ActivityController.class);

    @Autowired
    private CategoryService categoryService;
    @Autowired
    private ActivityService activityService;

    @Autowired
    private CommanderListService commanderListService;

    @Autowired
    private ProductSkuCentreMapper productSkuCentreMapper;
    @Autowired
    private MemberService memberService;
    @Autowired
    private StoreFreeChargeService storeFreeChargeService;
    @Autowired
    private ActivityProductMapper activityProductMapper;
    @Autowired
    private ProductAuthorityService productAuthorityService;

    /**
     * 跳转页面：秒杀页面
     *
     * @return
     */
    @GetMapping("/toFullGiftActivtyPage")
    @RequiresPermissions("activit:manage:view")
    public String toSeckillPage(Model model) {
        Category category = new Category();
        category.setParentid(0L);
        //活动类型
        model.addAttribute("activityType", ActivityType.FULL_GIFT.getType());
        model.addAttribute("category", categoryService.getListCategory(category));
        model.addAllAttributes(getCentreIdModelInfo());
        return prefix + "/fullGiftActivitys";
    }

    @ResponseBody
    @GetMapping("/freechargeList")
    public PageUtils<StoreFreecharge> listStoreFreeCharge(@RequestParam Map<String,Object> params) {
        return storeFreeChargeService.list(params);
    }

    /**
     * 跳转页面：优惠套装页面
     *
     * @return
     */
    @GetMapping("/toFreeChargePage")
    @RequiresPermissions("activity:freecharge:view")
    public String toFreeChargePage(Model model) {
        Category category = new Category();
        category.setParentid(0L);
        //活动类型
        model.addAttribute("activityType", ActivityType.FREECHARGE.getType());
        model.addAttribute("category", categoryService.getListCategory(category));
        model.addAllAttributes(getCentreIdModelInfo());
        return prefix + "/freecharge/freechargeActivitys";
    }

    /**
     * 跳转到设置权限页面
     *
     * @param id
     * @param model
     * @return
     * @author baolingyu
     * @date 2018年8月28日-下午2:12:57
     */
    @RequiresPermissions("activit:manage:view")
    @GetMapping("/installAuthority/{id}")
    public String installAuthority(@PathVariable Long id, Model model) {
        model.addAttribute("productAuthorityList", productAuthorityService.listByAll());
        Activity activity = activityService.getActivityById(id);
        model.addAttribute("activity", activity);
        model.addAttribute("activityId", id);
        return prefix + "/freecharge/installAuthority";
    }

    /**
     * 编辑操作
     * @param activity
     * @return
     */
    @Log(module = "大礼包管理", operation = "编辑")
    @ResponseBody
    @RequiresPermissions("activit:manage:add")
    @PostMapping("/updateAuthority")
    public ResultVo updateAuthority(Activity activity) {
        if (activity == null || activity.getId() == null) {
            return ResultVo.error();
        }
        if (activityService.updateActivity(activity) < 1) {
            return ResultVo.error();
        }
        return ResultVo.ok();
    }

    /**
     * 跳转页面：优惠套装页面
     *
     * @return
     */
    @GetMapping("/toPackageActivtyPage")
    @RequiresPermissions("activit:manage:view")
    public String toPackageActivtyPage(Model model) {
        Category category = new Category();
        category.setParentid(0L);
        //活动类型
        model.addAttribute("activityType", ActivityType.PACKAGE.getType());
        model.addAttribute("category", categoryService.getListCategory(category));
        model.addAllAttributes(getCentreIdModelInfo());
        return prefix + "/package/packageActivitys";
    }

    /**
     * 列表 获取秒杀列表
     *
     * @param offset
     * @param limit
     * @param activityParam
     * @return
     */
    @GetMapping("/listAll")
    @ResponseBody
    @RequiresPermissions("activit:manage:view")
    public PageUtils<Activity> listAll(int offset, int limit, ActivityParam activityParam) {
        if (activityParam.getCentreId() == null) {
            activityParam.setCentreId(getUserCentreId());
        }
        if (activityParam.getTeamId() == null) {
            activityParam.setTeamId(getUserTeamId());
        }
        return activityService.listAll(offset, limit, activityParam);
    }

    /**
     * 跳转页面：选择商品页面
     *
     * @return
     */
    @GetMapping("/toChooseGiftBag")
    public String toChooseGiftBag(Model model) {
        ListMemberParams listMemberParams = new ListMemberParams();
        if (getUserCentreId() != null) {
            listMemberParams.setCentreId(getUserCentreId());
        }

        Map<String, Object> map = getCentreIdModelInfo();
        List<Member> teams = commanderListService.listCommanders(listMemberParams, new Member());
        model.addAttribute("teams", teams);
        model.addAllAttributes(map);
        return "marketing/chooseGiftBag";
    }

    /**
     * 选择商品
     *
     */
    @GetMapping("/chooseGiftBagList")
    @ResponseBody
    public PageUtils<Activity> chooseGiftBagList(int offset, int limit, ActivityParam activityParam) {
        if(activityParam.getCentreId() == null){
            activityParam.setCentreId(getUserCentreId());
        }
        if(activityParam.getTeamId() == null){
            activityParam.setTeamId(getUserTeamId());
        }

        return activityService.listAll(offset, limit, activityParam);

    }

    /**
     * 跳转页面：新增拼团页面
     *
     * @return
     */
    @GetMapping("/toActivityAdd")
    @RequiresPermissions("activit:manage:add")
    public String toActivityAdd(Model model, Integer type) {
        model.addAllAttributes(getCentreIdModelInfo());
        String pageUrl = prefix + "/addFullGiftActivity";
        if (ActivityType.PACKAGE.getType() == type) {//优惠套装
            pageUrl = prefix + "/package/addPackageActivity";
        } else if (ActivityType.FREECHARGE.getType() == type) {//免单活动
            pageUrl = prefix + "/freecharge/addFreechargeActivity";
        }
        return pageUrl;
    }


    /**
     * 跳转页面：选择商品页面
     *
     * @return
     */
    @GetMapping("/toChooseProduct")
    @RequiresPermissions("activit:manage:chooseproduct")
    public String toChooseProduct(Model model) {
        ListMemberParams listMemberParams = new ListMemberParams();
        if (getUserCentreId() != null) {
            listMemberParams.setCentreId(getUserCentreId());
        }

        Map<String, Object> map = getCentreIdModelInfo();
        List<Member> teams = commanderListService.listCommanders(listMemberParams, new Member());
        model.addAttribute("teams", teams);
        model.addAllAttributes(map);
        return prefix + "/chooseProduct";
    }


    /**
     * 跳转页面：选择商品页面
     *
     * @return
     */
    @GetMapping("/toChooseCoupon")
    @RequiresPermissions("activit:manage:chooseproduct")
    public String toChooseCoupon(Model model, Integer activityType, Long activityId) {
        ListMemberParams listMemberParams = new ListMemberParams();
        if (getUserCentreId() != null) {
            listMemberParams.setCentreId(getUserCentreId());
        }

        Map<String, Object> map = getCentreIdModelInfo();
        List<Member> teams = commanderListService.listCommanders(listMemberParams, new Member());
        model.addAttribute("teams", teams);
        model.addAttribute("activityType", activityType);
        model.addAttribute("activityId", activityId);
        model.addAllAttributes(map);
        return prefix + "/package/chooseCoupon";
    }


    /**
     * 跳转页面：选择商品页面
     *
     * @return
     */
    @GetMapping("/toGiftProductSpecSelect")
    public String toProductGroupStockSetting(Model model, @RequestParam("productId") Long productCentreId) {
        model.addAttribute("productCentreId", productCentreId);
        return prefix + "/giftProductSpecSelect";
    }

    @GetMapping("/listAllSkuByProductId")
    @ResponseBody
//    @RequiresPermissions("product:manage:manage")
    public PageUtils<ProductSkuCentre> listAllSkuByProductId(@RequestParam("productCentreId") Long productCentreId) {
        PageUtils<ProductSkuCentre> pageUtils = new PageUtils<>();
        List<ProductSkuCentre> list = productSkuCentreMapper.getByProductId(productCentreId);
        pageUtils.setTotal(list == null ? 0 : list.size());
        pageUtils.setRows(list == null ? Collections.EMPTY_LIST : list);
        return pageUtils;
    }

    @GetMapping("/listAllGroupByProductId")
    @ResponseBody
//    @RequiresPermissions("product:manage:manage")
    public PageUtils<ActivityProductSku> llSeckillSkuByProductId(@RequestParam("productCentreId") Long productCentreId) {
        PageUtils<ActivityProductSku> pageUtils = new PageUtils<>();
        List<ActivityProductSku> list = activityService.listActivityProductSkuByProductId(productCentreId);
        pageUtils.setTotal(list == null ? 0 : list.size());
        pageUtils.setRows(list == null ? Collections.EMPTY_LIST : list);
        return pageUtils;
    }

    @GetMapping("/listAllProduct")
    @ResponseBody
    public PageUtils<ActivityProduct> listAllProduct(@RequestParam("activityId") Long activityId, @RequestParam("type") Integer type) {
        PageUtils<ActivityProduct> pageUtils = new PageUtils<>();
        List<ActivityProduct> list = activityService.listActivityProductsByActivityId(activityId, type);
        pageUtils.setTotal(list == null ? 0 : list.size());
        pageUtils.setRows(list == null ? Collections.EMPTY_LIST : list);
        return pageUtils;
    }

    @GetMapping("/listAllProductSku")
    @ResponseBody
    public PageUtils<ActivityProductSku> listAllProductSku(@RequestParam("activityId") Long activityId, @RequestParam("type") Integer type) {
        PageUtils<ActivityProductSku> pageUtils = new PageUtils<>();
        List<ActivityProductSku> list = activityService.listActivityProductSkusByActivityId(activityId, type);
        pageUtils.setTotal(list == null ? 0 : list.size());
        pageUtils.setRows(list == null ? Collections.EMPTY_LIST : list);
        return pageUtils;
    }


    /**
     * 跳转页面：选择商品页面
     *
     * @return
     */
    @GetMapping("/toChooseJoinProduct")
    @RequiresPermissions("activit:manage:chooseproduct")
    public String toChooseJoinProduct(Model model, Integer activityType, Long activityId) {
        ListMemberParams listMemberParams = new ListMemberParams();
        if (getUserCentreId() != null) {
            listMemberParams.setCentreId(getUserCentreId());
        }

        Map<String, Object> map = getCentreIdModelInfo();
        List<Member> teams = commanderListService.listCommanders(listMemberParams, new Member());
        model.addAttribute("teams", teams);
        model.addAttribute("isJoinProduct", 1);
        model.addAttribute("activityType", activityType);
        model.addAttribute("activityId", activityId);
        model.addAllAttributes(map);
        return prefix + "/chooseProduct";
    }


    /**
     * 跳转页面：选择商品页面
     *
     * @return
     */
    @GetMapping("/toChooseJoinShop")
    public String toChooseJoinShop(Model model, Integer activityType, Long activityId) {
        ListMemberParams listMemberParams = new ListMemberParams();
        if (getUserCentreId() != null) {
            listMemberParams.setCentreId(getUserCentreId());
        }

        Map<String, Object> map = getCentreIdModelInfo();
        List<Member> teams = commanderListService.listCommanders(listMemberParams, new Member());
        model.addAttribute("teams", teams);
        model.addAttribute("activityType", activityType);
        model.addAttribute("activityId", activityId);
        model.addAllAttributes(map);
        return prefix + "/freecharge/chooseShop";
    }

    /**
     * 列表 获取门店列表
     *
     * @param activityParam
     * @return
     */
    @GetMapping("/listAllShop")
    @ResponseBody
    @RequiresPermissions("activit:manage:view")
    public PageUtils<Member> listAllShop(@RequestParam Map<String,Object> activityParam) {
        if (activityParam.get("centreId") == null || ValidateUtil.isEmptyString(activityParam.get("centreId").toString())) {
            activityParam.put("centreId",getUserCentreId());
        }
        if (activityParam.get("teamId") == null || ValidateUtil.isEmptyString(activityParam.get("teamId").toString())) {
            activityParam.put("teamId",getUserTeamId());
        }
        return memberService.listAllShops(activityParam);
    }

    /**
     * 跳转页面：选择商品页面
     *
     * @return
     */
    @GetMapping("/toJoinProductSpecSelect")
    public String toJoinProductSpecSelect(Model model, @RequestParam("productId") Long productCentreId) {
        model.addAttribute("productCentreId", productCentreId);
        model.addAttribute("isJoinProduct", 1);
        return prefix + "/joinProductSpecSelect";
    }


    /**
     * 跳转页面：选择商品页面
     *
     * @return
     */
    @GetMapping("/toProductSpecSelect")
    public String toProductSpecSelect(Model model, @RequestParam("productId") Long productId, Long activityId) {
        model.addAttribute("productId", productId);
        model.addAttribute("activityId", activityId);
        return prefix + "/package/productSpecSelect";
    }


//    /**
//     * 跳转页面：选择商品页面
//     *
//     * @return
//     */
//    @PostMapping("/saveActivity")
//    public String saveActivity(Model model, ActivityParam activityParam) {
//        return activityService.saveActivity(activityParam);
//    }

    /**
     * 数据保存 修改
     *
     * @return
     */
    @Log(module = "营销活动管理", operation = "新增或修改活动")
    @ResponseBody
    @RequiresPermissions("activit:manage:add")
    @PostMapping("/saveActivity")
    public ResultVo saveActivity(@RequestBody ActivityParam params) {
        if (params == null) {
            return ResultVo.error();
        }
        //添加
        if (params.getId() == null) {
            if (params.getCentreId() == null) {
                params.setCentreId(getUserCentreId());
            }
            if (params.getTeamId() == null) {
                params.setTeamId(getUserTeamId());
            }
            Long activityId = activityService.saveActivity(params);
            if (activityId != null) {
                return ResultVo.ok().put("data", activityId);
            } else {
                return ResultVo.error();
            }
        } else {
            //修改
            int updNum = activityService.updateActivity(params);
            if (updNum > 0) {
                return ResultVo.ok();
            } else {
                return ResultVo.error();
            }
        }
    }


    /**
     * 跳转到编辑页面
     *
     * @param id
     * @param model
     * @return
     * @author baolingyu
     * @date 2018年8月28日-下午2:12:57
     */
    @RequiresPermissions("activit:manage:add")
    @GetMapping("/edit/{id}")
    public String activityEdit(@PathVariable Long id, Model model, Integer type) {
        Long centreId = getUserCentreId();
        ListMemberParams listMemberParams = new ListMemberParams();
        if (centreId != null) {
            listMemberParams.setCentreId(centreId);
        }
        Map<String, Object> map = getCentreIdModelInfo();
        List<Category> categorys = null;
        //商户
//        if (StringUtils.isNotEmpty(map.get("flag").toString()) && map.get("flag").equals("1")) {
//            Category category = new Category();
//            category.setParentid(0L);
//            category.setCentreId(new Long(map.get("centreId").toString()));
//            categorys = categoryService.getListCategory(category);
//        } else {
//            categorys = categoryService.listCategorys(0L);
//        }
        List<Member> teams = commanderListService.listCommanders(listMemberParams, new Member());
        model.addAttribute("teams", teams);
        //判断连锁店ID是否存在，不存在，表示是商户超级管理员账号
        Long teamId = getUserTeamId();
        if (null != teamId) {
            model.addAttribute("teamId", teamId);
        }
        Activity activity = activityService.getActivityById(id);
        model.addAttribute("activity", activity);
        model.addAttribute("activityId", id);
        ActivityProductExample example = new ActivityProductExample();
        example.createCriteria().andActivityIdEqualTo(id);
        //参与商品
        example.createCriteria().andTypeEqualTo(type);
        model.addAttribute("activityJoinProductList", activityService.selectByExample(example));
        String jumpUrl = prefix + "/editFullGiftActivity";
        //赠品
        if (type == ActivityType.FULL_GIFT.getType()) {
            example.createCriteria().andTypeEqualTo(ActivityType.GIFT_PRODUCT.getType());
            model.addAttribute("activityGiftProductList", activityService.selectByExample(example));
        }
        model.addAllAttributes(map);
        model.addAllAttributes(getCentreIdModelInfo());
        if (type == ActivityType.PACKAGE.getType()) {
            jumpUrl = prefix + "/package/editPackageActivity";
        }else if (type == ActivityType.FREECHARGE.getType()) {
            jumpUrl = prefix + "/freecharge/editFreechargeActivity";
        }

        return jumpUrl;
    }


    /**
     * 删除标签
     *
     * @param id
     * @return
     */
    @Log(module = "营销活动管理", operation = "删除")
    @ResponseBody
    //@RequiresPermissions("activit:manage:delete")
    @PostMapping("/remove")
    public ResultVo remove(Long id) {
        if (id == null) {
            return ResultVo.error();
        }

        activityService.removeActivity(id);

        return ResultVo.ok();
    }

    /**
     * 删除标签
     *
     * @param id
     * @return
     */
    @Log(module = "营销活动管理", operation = "删除活动产品")
    @ResponseBody
    //@RequiresPermissions("activit:manage:delete")
    @PostMapping("/removeActivityProduct")
    public ResultVo removeActivityProduct(Long id) {
        if (id == null) {
            return ResultVo.error();
        }

        activityService.removeActivityProduct(id);

        return ResultVo.ok();
    }

    /**
     * 批量选择门店商品
     */
    @Log(module = "营销活动管理", operation = "批量选择门店商品")
    @ResponseBody
    @PostMapping("/batch/selectStoreFreecharge")
    public ResultVo batchSelectStoreFreecharge(Long activityProductId,@RequestParam("ids[]")Long[] ids) {
        if (activityProductId == null) {
            return ResultVo.error();
        }
        if (ids == null || ids.length <= 0) {
            return ResultVo.error();
        }
        ActivityProduct record = new ActivityProduct();
        record.setId(activityProductId);
        record.setFreechargeId(StringUtils.join(ids,","));
        activityProductMapper.updateByPrimaryKeySelective(record);

        activityService.deleteAndInsert(activityProductId,1,ids);

        return ResultVo.ok();
    }

    /**
     * 批量选择门店商品
     */
    @Log(module = "营销活动管理", operation = "批量选择门店优惠券")
    @ResponseBody
    @PostMapping("/batch/selectStoreFreechargeCoupon")
    public ResultVo batchSelectStoreFreechargeCoupon(Long activityProductId,@RequestParam("ids[]")Long[] ids) {
        if (activityProductId == null) {
            return ResultVo.error();
        }
        if (ids == null || ids.length <= 0) {
            return ResultVo.error();
        }
        ActivityProduct record = new ActivityProduct();
        record.setId(activityProductId);
        record.setCouponIds(StringUtils.join(ids,","));
        activityProductMapper.updateByPrimaryKeySelective(record);

        activityService.deleteAndInsert(activityProductId,2,ids);

        return ResultVo.ok();
    }


    /**
     * 查询大礼包活动选择的所有商品
     */
    @Log(module = "营销活动管理", operation = "查询活动选择的所有商品")
    @ResponseBody
    @GetMapping("/selectAll/activityProduct")
    public PageUtils<StoreFreechargeVo> selectAllActivityProduct(Long activityId,Integer type) {
        if (activityId == null) {
            return new PageUtils<>();
        }
        PageUtils<StoreFreechargeVo> pageUtils = new PageUtils<>();
        List<StoreFreechargeVo> list = activityService.selectAllActivityProduct(activityId,type);
        pageUtils.setTotal(list == null ? 0 : list.size());
        pageUtils.setRows(list == null ? Collections.EMPTY_LIST : list);
        return pageUtils;
    }

    @Log(module = "营销活动管理", operation = "查询活动选择的所有优惠券")
    @ResponseBody
    @GetMapping("selectAll/activityProductCoupon")
    public PageUtils<StoreFreechargeVo> selectActivityProductCoupon(Long activityId,Integer type) {
        if (activityId == null) {
            return new PageUtils<>();
        }
        PageUtils<StoreFreechargeVo> pageUtils = new PageUtils<>();
        List<StoreFreechargeVo> list = activityService.selectAllActivityProductCoupon(activityId,type);
        pageUtils.setTotal(list == null ? 0 : list.size());
        pageUtils.setRows(list == null ? Collections.EMPTY_LIST : list);
        return pageUtils;
    }

    /**
     * 选择门店商品
     *
     * @param teamId
     */
    @Log(module = "营销活动管理", operation = "选择门店商品")
    @GetMapping("/selectStoreFreecharge")
    public String selectStoreFreecharge(Model model, Long id) {
        ActivityProduct activityProduct = activityProductMapper.selectByPrimaryKey(id);
        model.addAttribute("teamId",activityProduct.getProductId());
        model.addAttribute("activityProductId",id);
        return prefix + "/freecharge/chooseStoreFreecharge";
    }

    /**
     * 选择门店优惠券
     *
     * @param teamId
     */
    @Log(module = "营销活动管理", operation = "选择门店商品")
    @GetMapping("/selectStoreFreechargeCoupon")
    public String selectStoreFreechargeCoupon(Model model, Long id, BigDecimal activityPrice, BigDecimal vipPrice) {
        ActivityProduct activityProduct = activityProductMapper.selectByPrimaryKey(id);
        model.addAttribute("teamId",activityProduct.getProductId());
        model.addAttribute("activityProductId",id);
        model.addAttribute("activityPrice",activityPrice);
        model.addAttribute("vipPrice",vipPrice);
        return prefix + "/freecharge/chooseStoreFreechargeCoupon";
    }

    /**
     * 删除标签
     *
     * @param id
     * @return
     */
    @Log(module = "营销活动管理", operation = "删除活动产品")
    @ResponseBody
    //@RequiresPermissions("activit:manage:delete")
    @PostMapping("/removeActivityProductSku")
    public ResultVo removeActivityProductSku(Long id) {
        if (id == null) {
            return ResultVo.error();
        }

        activityService.removeActivityProductSku(id);

        return ResultVo.ok();
    }

    /**
     * 删除标签
     *
     * @param activityProduct
     * @return
     */
    @Log(module = "营销活动管理", operation = "添加活动产品")
    @ResponseBody
    @RequiresPermissions("activit:manage:add")
    @PostMapping("/addActivityProduct")
    public ResultVo addActivityProduct(@RequestBody ActivityProduct activityProduct) {

        activityService.addActivityProduct(activityProduct);

        return ResultVo.ok();
    }

    /**
     * 删除标签
     *
     * @param activityProduct
     * @return
     */
    @Log(module = "营销活动管理", operation = "添加活动产品")
    @ResponseBody
    @RequiresPermissions("activit:manage:add")
    @PostMapping("/addActivityProductSku")
    public ResultVo addActivityProductSku(@RequestBody ActivityProductSku activityProductSku) {

        activityService.addActivityProductSku(activityProductSku);

        return ResultVo.ok();
    }

    /**
     * 删除标签
     *
     * @param activityProduct
     * @return
     */
    @Log(module = "营销活动管理", operation = "编辑活动产品")
    @ResponseBody
    @RequiresPermissions("activit:manage:edit")
    @PostMapping("/editActivityProduct")
    public ResultVo editActivityProduct(@RequestBody ActivityProduct activityProduct) {

        activityService.editActivityProduct(activityProduct);

        return ResultVo.ok();
    }

    @GetMapping("/listAllSkuByProductIdNew")
    @ResponseBody
//    @RequiresPermissions("product:manage:manage")
    public PageUtils<ProductSkuCentre> listAllSkuByProductIdNew(@RequestParam("productCentreId") Long productCentreId, Long activityId) {
        PageUtils<ProductSkuCentre> pageUtils = new PageUtils<>();
        List<ProductSkuCentre> list = productSkuCentreMapper.getByProductIdNew(productCentreId, activityId);
        pageUtils.setTotal(list == null ? 0 : list.size());
        pageUtils.setRows(list == null ? Collections.EMPTY_LIST : list);
        return pageUtils;
    }

}
